<?php
namespace Users;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
use Users\Model\User;
use Users\Model\UserTable;
use Users\Model\Categories;
use Users\Model\CategoriesTable;
use Application\Model\Cities;
use Application\Model\CitiesTable;
use Users\Model\AdminCombinations;
use Users\Model\AdminCombinationsTable;
use Users\Model\UserRegions;
use Users\Model\UserRegionsTable;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Users\Model\Forgetpassword;
use Users\Model\ForgetpasswordTable;
use Zend\ModuleManager\Feature;
use Zend\Loader;
use Zend\EventManager\EventInterface;
use Zend\Mvc\Router\RouteMatch;
use Zend\ModuleManager\ModuleManager;
use Zend\Stdlib\Hydrator\ClassMethods;

//new
use Users\Model\Usersnew;
use Users\Model\UsersnewTable;
//admin
use Users\Model\Admin;
use Users\Model\AdminTable;

class Module implements 
	Feature\AutoloaderProviderInterface,
    Feature\ConfigProviderInterface,
    Feature\ServiceProviderInterface
{
    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\ClassMapAutoloader' => array(
                __DIR__ . '/autoload_classmap.php',
            ),
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                ),
            ),
        );
    }
    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }    
    public function getServiceConfig()
    {
        return array(
			
            'factories' => array( 
				'Users\Model\UserTable' =>  function($sm) {
                   $tableGateway = $sm->get('UserTableGateway');
                   $table = new UserTable($tableGateway);
                   return $table;
                },
                'UserTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new User());
                    return new TableGateway('users', $dbAdapter, null, $resultSetPrototype);
                },
				//new
				'Users\Model\UsersnewTable' =>  function($sm) {
                   $tableGateway = $sm->get('UsersnewTableGateway');
                   $table = new UsersnewTable($tableGateway);
                   return $table;
                },
                'UsersnewTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new Usersnew());
                    return new TableGateway('users_new', $dbAdapter, null, $resultSetPrototype);
                },
				
				'Users\Model\ForgetpasswordTable' =>  function($sm) {
                   $tableGateway = $sm->get('ForgetpasswordTableGateway');
                   $table = new ForgetpasswordTable($tableGateway);
                   return $table;
                },
                'ForgetpasswordTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new Forgetpassword());
                    return new TableGateway('forgetpassword', $dbAdapter, null, $resultSetPrototype);
                },
				//admintable
				'Users\Model\AdminTable' =>  function($sm) {
                   $tableGateway = $sm->get('AdminTableGateway');
                   $table = new AdminTable($tableGateway);
                   return $table;
                },
                'AdminTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new Admin());
                    return new TableGateway('super_admin', $dbAdapter, null, $resultSetPrototype);
                },
				//'Users\Model\UsersNewTableFactory'=>'Users\Factory\Model\UsersNewTableFactory',
				//'Users\Model\BusinessTable' =>  'Users\Factory\Model\BusinessTableFactory',
				'Users\Model\AdminCombinationsTable' =>  function($sm) {
                   $tableGateway = $sm->get('AdminCombinationsTableGateway');
                   $table = new AdminCombinationsTable($tableGateway);
                   return $table;
                },
                'AdminCombinationsTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new AdminCombinations());
                    return new TableGateway('admin_combinations', $dbAdapter, null, $resultSetPrototype);
                },
				'Users\Model\UserRegionsTable' =>  function($sm) {
					   $tableGateway = $sm->get('UserRegionsTableGateway');
					   $table = new UserRegionsTable($tableGateway);
					   return $table;
				},
				'UserRegionsTableGateway' => function ($sm) {
					$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
					$resultSetPrototype = new ResultSet();
					$resultSetPrototype->setArrayObjectPrototype(new UserRegions());
					return new TableGateway('user_regions', $dbAdapter, null, $resultSetPrototype);
				},
				'HybridAuth' => 'ScnSocialAuth\Service\HybridAuthFactory',
				'ScnSocialAuth-ModuleOptions' => 'ScnSocialAuth\Service\ModuleOptionsFactory',
				'ScnSocialAuth-UserProviderMapper' => 'ScnSocialAuth\Service\UserProviderMapperFactory',
				'ScnSocialAuth\Authentication\Adapter\HybridAuth' => 'ScnSocialAuth\Service\HybridAuthAdapterFactory',
				'ZfcUser\Authentication\Adapter\AdapterChain' => 'ScnSocialAuth\Service\AuthenticationAdapterChainFactory',				
            ),
			
        );
    }
}